package com.dto.merchant;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class PermissionDataModel extends ListDataModel<PermissionDTO>
		implements SelectableDataModel<PermissionDTO>, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6217482800111244180L;

	public PermissionDataModel() {
	}

	public PermissionDataModel(List<PermissionDTO> list) {
		super(list);
		// TODO Auto-generated constructor stub
	}

	@SuppressWarnings("unchecked")
	@Override
	public PermissionDTO getRowData(String rowKey) {
		List<PermissionDTO> list=(List<PermissionDTO>) getWrappedData();
		for(PermissionDTO dto: list){
			if(String.valueOf(dto.getPermissionId()).equals(rowKey)){
				return dto;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(PermissionDTO dto) {
		// TODO Auto-generated method stub
		return dto.getPermissionId();
	}

}
